package com.contacts.mapper;

import com.contacts.pojo.Contact;
import com.contacts.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 用户登录
     * @param user
     * @return
     */
    @Select("select user_id,user_name,user_password,user_phone from users where user_phone=#{userPhone} and user_password =#{userPassword}")
    public User getByUserphoneAndUserpassword(User user);

    /**
     * 添加新用户
     * @param user
     */
    @Insert("insert into users(user_name, user_password, user_phone) values (#{userName},#{userPassword},#{userPhone})")
    void insertUser(User user);

    /**
     * 联系人分页查询
     * @param category
     * @param name
     * @param userIdFromToken
     * @return
     */
    List<Contact> list(String category, String name, Integer userIdFromToken);
}
